-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor footprint changes #167
base: main
Are you sure you want to change the base?
Conversation
…into a single parameterized function extract_footprint(footprint_dict, footprint_key). Removed the print missing kwh/co2, footprint_dict since it was polluting the cell execution, and in all these cases footprint_dict was empty.
…he actual exception error reason, also while accounting the total number of trips where there were errors.
…red from prior labels
…book_inferred_data(,..,add_footprint). Use base_mode AIR to filter out the trip without air mode, instead of internal label
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a couple questions/suggestions below!
def extract_footprint(footprint_dict, footprint_key): | ||
if footprint_key in footprint_dict.keys(): | ||
return footprint_dict[footprint_key] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good refactor
@@ -254,7 +257,7 @@ async def map_trip_data(expanded_trip_df, study_type, dynamic_labels): | |||
|
|||
return expanded_trip_df | |||
|
|||
async def load_viz_notebook_inferred_data(year, month, program, study_type, dynamic_labels, include_test_users=False): | |||
async def load_viz_notebook_inferred_data(year, month, program, study_type, dynamic_labels, include_test_users=False, add_footprint=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my understanding, is this cleanup from something that was meant to be added in a previous PR?
I saw that load_viz_notebook_data
already had the add_footprint
parameter, but load_viz_notebook_inferred_data
was missing it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is not a cleanup which was meant to be added in the previous PR. We were using add_footprint
parameter to compute footprint calculations in labeled trips
in energy_calculations
notebook. Earlier, we were not using add_footprint
parameter for load_viz_notebook_inferred_data
.
We need to pass add_footprint
parameter as True
to enable extraction of base_mode
. Therefore, this change is required, such that we have base_mode
as column added in the expanded_ct_inferred
data frame. This enables us for filtering AIR as the base_mode, instead of using mode_confirm_w_other = 'air'.
@@ -244,7 +246,7 @@ | |||
" plot_and_text_stacked_bar_chart(expanded_ct, lambda df: (df.groupby(\"mode_confirm_w_other\").agg({distance_col: 'count'}).sort_values(by=distance_col, ascending=False)), \n", | |||
" \"Labeled by user\\n\"+stacked_bar_quality_text_labeled, ax[0], text_results[0], colors_mode, debug_df, values_to_translations)\n", | |||
" plot_and_text_stacked_bar_chart(expanded_ct_inferred, lambda df: (df.groupby(\"mode_confirm_w_other\").agg({distance_col: 'count'}).sort_values(by=distance_col, ascending=False)), \n", | |||
" \"Labeled and Inferred by OpenPATH\\n\"+stacked_bar_quality_text_inferred, ax[1], text_results[1], colors_mode, debug_df_inferred, values_to_translations)\n", | |||
" \"Inferred from prior labels\\n\"+stacked_bar_quality_text_inferred, ax[1], text_results[1], colors_mode, debug_df_inferred, values_to_translations)\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good text change. More concise & clearer
Co-authored-by: Jack Greenlee <[email protected]>
Co-authored-by: Jack Greenlee <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Handle Future cleanups mentioned in #152 Changes:
Type fixed from relecant to relevant.
Refactor extract_co2 and extract_kwh to a single consolidated parameterized function extract_footprint()